#include <stdio.h>

int narcissistic(int number);
void PrintN(int m, int n);

int main()
{
    int m, n;

    scanf_s("%d %d", &m, &n);
    if (narcissistic(m)) printf("%d is a narcissistic number\n", m);
    PrintN(m, n);
    if (narcissistic(n)) printf("%d is a narcissistic number\n", n);

    return 0;
}
int narcissistic(int number) {
    int i, f, a, count = 0, s = 0, m = 1, o = number, p = number;
    while (o) { o /= 10; count++; }
    while (number) {
        a = number % 10; m = 1;
        for (i = 1; i < count + 1; i++) m *= a;
        s += m;
        number /= 10;


    }

    if (s == p) f = 1;
    else f = 0;
    return f;

}
void PrintN(int m, int n) {
    int i;
    for (i = m + 1; i < n; i++)
    {
        if (narcissistic(i) == 1)
            printf("%d\n", i);
    }




}